//
//  SettingViewController.m
//  iphone-graph
//
//  Created by yuzhuo on 2016/12/27.
//  Copyright © 2016年 yzapp. All rights reserved.
//

#import "SettingViewController.h"
#import "Constant.h"
#import "SelfTableCell.h"

@interface SettingViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) UITableView * tabView;

/** data */
@property (nonatomic,strong) NSMutableArray<NSString *> *data;
@end

@implementation SettingViewController

-(instancetype) init
{
    self = [super init];
    if(self){
        self.tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStyleGrouped];
        
        self.tabView.dataSource = self;
        self.tabView.delegate = self;
        [self initData];
    }
    return self;
}

-(void) initData{
    
    _data = [NSMutableArray new];
    [_data addObject:@"版本更新"];
    [_data addObject:@"退出"];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blackColor];
    [self.view addSubview:self.tabView];
    self.tabView.frame = self.view.bounds;
    //    self.tabView.backgroundColor = [UIColor whiteColor];
    [self.tabView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight ];
    self.tabView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.title = @"设置";
    
    // Do any additional setup after loading the view, typically from a nib.
}

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
    return self.data.count;
    
}

-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001f;
}

-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if(section == 0)
        return 20;
    return 15;
}


-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 50;
}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    static NSString *cellID = @"cellID";
    SelfTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil){
        cell = [[SelfTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    if(indexPath.section < self.data.count){
        cell.data = self.data[indexPath.section];
    }
    return cell;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
//    if(indexPath.section == 0){
//        SelfInfoEditViewController *detailview = [SelfInfoEditViewController new];
//        NSLog(@"click row%ld",indexPath.row);
//        [self.navigationController pushViewController:detailview animated:YES];
//    }
    
}

@end
